/*
 * Copyright 2010. 
 * 
 * This document may not be reproduced, distributed or used 
 * in any manner whatsoever without the expressed written 
 * permission of xrkol Corp. 
 * 
 * $Rev: Rev $
 * $Author: Author $
 * $LastChangedDate: LastChangedDate $
 *
 */

package com.xrkol.sharelib.dao.impl;

import java.util.List;

import org.springframework.stereotype.Repository;

import com.xrkol.sharelib.dao.AdultDao;
import com.xrkol.sharelib.entity.User;

/**
 * @author peng.xia
 *
 */
@Repository
public class AdultDaoImpl extends BaseDaoImpl<User, String> implements AdultDao{

    @Override
    public User findByNameAndPhone(String name, String phone) {
        System.out.println(getCurrentSchoolId());
        String queryString="from Adult g where g.name=? and g.phone=?";
        List<User> guardians=executeQueryWithoutPaging(queryString,name,phone);
        return guardians.size()>0?guardians.get(0):null;
    }

    @Override
    public User findByUserId(String userId) {
        String queryString="from Adult g where g.userId = ?";
        List<User> adults=executeQueryWithoutPaging(queryString,userId);
        return adults.size()>0?adults.get(0):null;
    }

    @Override
    public List<User> listAll(Integer page) {
        String queryString="from Adult";
        return executeQueryWithPagination(queryString, null, page);
    }

    @Override
    public List<User> getAll() {
        String queryString="from Adult";
        return executeQueryWithoutPaging(queryString);
    }

}
